home *** CD-ROM | disk | FTP | other *** search
- MAND
- Version 1.3
- 4 November 1996
-
- ------------------------
- Gregory Kwok
- 142 Armstrong Court
- Hercules, CA 94547 USA
- <gkwok@california.com>
- ------------------------
-
- MAND system requirements:
- ■ An 80286 processor, but the faster the better (P6?)
- ■ A VGA graphics adapter that supports 640x480x16 color mode.
- ■ A Microsoft compatible mouse if you want to zoom in or analyze the
- different areas of the fractal, otherwise you cannot view more than
- the initial range.
- ■ A 80x87 or higher math coprocessor is *strongly* recommended. The
- first range takes over an hour to draw on a 386 without one, and about
- 25 seconds on my Pentium 133.
-
- This program is dedicated to drawing "the" Mandelbrot fractal set, whose
- discovery is generally credited to Benoit Mandelbrot, a French mathematician.
- A fractal is a self-similar object or image that retains its complexity and
- detail at any level of magnification. A simple fractal is a tree: a branch
- can be magnified to resemble the entire tree. A twig on this branch has
- small sprouts that resemble the tree, and so on with these sprouts, and
- "twiglets" and "sproutlets", all which bear similarity to the original tree.
-
- One well-known fractal is the Koch snowflake curve. First, start with an
- equilateral triangle with sides of length k. Now, trisect each side and
- remove the middle segment (whose length is k/3). Construct a new equilateral
- triangle in place of the missing middle segments each with sides of length
- k/3. At this stage the "snowflake" looks more like the Jewish Star of David.
- Now take all these smaller triangles and trisect *their* sides and
- construct new equilateral triangles, whose lengths will be k/9. Continue
- trisecting the new triangles' sides and constructing new equilateral tri-
- angles, and you will end up with the Koch snowflake curve. [using calculus,
- one can prove that the area of the entire snowflake is 8/5 of the area of
- the original triangle. However, because there are an infinite number of
- triangles, the perimeter of the snowflake is infinite!]
-
- Another famous fractal is the Sierpinski triangle, or Sierpinski gasket.
- This fractal destroys the original image instead of adding to it. First,
- as with the Koch snowflake, draw an equilateral triangle. Bisect each side
- and connect the bisecting points to form a new equilateral triangle. (if the
- original triangle pointed "up", then this new triangle points "down") Color
- in the new triangle.
- There are now three small white equilateral triangles. Bisect their sides
- and color in the resulting equilateral triangle. If the colored areas are
- considered to be void, while the white areas are considered part of the
- gasket, we have two seemingly contradictory facts: (1) the perimeter of the
- Sierpinski gasket is infinite, and (2) its area approaches 0 as a limit.
-
- Fractals can also be mathematical images that are described by a formula
- rather than words, and the Mandelbrot set is one example. However, before I
- delve into the construction of the Mandelbrot set, we must take a brief
- review/refresh of the complex numbers. Those of you who are well-versed in
- complex numbers can skip the next section.
- ===============================================================================
- Most numbers you are familiar with are *real numbers*. These include such
- numbers as 0, 97, 2.718, -0.25, π, √2, 1/3. However, consider the quadratic
- equation x²+1 = 0. There is no solution unless we set x to √-1, which intro-
- duces the complex number set, denoted as "C" (the real set is denoted as "R").
- A complex number is the sum of a real number and an imaginary number; it
- takes the general form (a + bi), where a and b are real, and i is the square
- root of -1. The following are all examples of complex numbers:
- (5 + 2i) (3 + 6i) (3 + i) (10 - 7i) (4 - 39i)
- (0 + 12i) = 12i (21 + 0i) = 21
- In the case where a=0, we are left with just 12i, which is called a *pure
- imaginary number.* When b=0 as in (21 + 0i) we are left with 21, which is
- a real number. Thus, all reals are complex numbers whose b=0.
- You can add, subtract, multiply, divide, and compare complex numbers. A
- complex number (a + bi) is equal to (c + di) if and only if a=c and b=d, and
- (a + bi) != (c + di) if a!=c or b!=d. You cannot use the inequality operators
- < ≤ > ≥ with complex numbers. For this discussion, we are primarily
- interested in adding and multiplying complex numbers.
- To add two complex numbers (a + bi) and (c + di), you simply combine the
- like terms: a and b, and bi and di. (a + bi) + (c + di) = a + bi + c + di =
- a + c + bi + di = (a + c) + (b + d)i. Subtraction follows thereafter:
- (a + bi) - (c + di) = a + bi - c - di = a - c + bi - di = (a - c) + (b - d)i.
- When multiplying, use the binomial expansion: (a + bi)(c + di) =
- ac + adi + bci + bdi². Since (√x)² = x, we can safely say that i² = -1. We
- get ac + adi + bci - bd──the i² drops out and changes the sign of its term.
- Continuing: ac - bd + adi + bci = (ac - bd) + (ad + bc)i.
- Summary: (a + bi) + (c + di) = (a + c) + (b + d)i
- (a + bi) - (c + di) = (a - c) + (b - d)i
- (a + bi)(c + di) = (ac - bd) + (ad + bc)i
- ===============================================================================
- The complex numbers can be graphed as points on a Cartesian plane as a
- means of representing them. The (x, y) coordinates correspond to a and b
- of (a + bi), where a is the real axis and b is the imaginary axis. THIS is
- what the Mandelbrot set is all about──quite simple after you examine the
- complexity of its results!
- Mandelbrot's formal definition of the Mandelbrot set is
- "All such µ...under z->z²-µ where z[0]=0 that do not converge to ∞."
- What does all this mean? Let me show an example. First, let z, a
- complex number, equal 0. Pick any complex number and call it µ. Now set z
- to z²-µ (or simply -µ in this case, since 0²=0), following the rules for
- complex multiplication and subtraction. Set z to z²-µ, which can be expanded
- to µ²-µ. Continue as many times as desired, setting z to z²-µ. One of two
- things will happen: z will converge to infinity, that is, its a and b values
- will approach infinity; or it will stay relatively small.
- For those such µ when z stays small, they are the elements of the Mandel-
- brot set. The µ when z approaches infinity are not. Take a look at the output
- of MAND if you wish, or see the graphics file MAND.GIF. The black areas are
- the complex numbers on a Cartesian plane that do not converge to infinity.
- The blue areas are the µ that converge to infinity rather quickly. The
- intermediate colors are chosen based on how quickly they increase in magni-
- tude and tend to infinity.
- But this image isn't self-similar! you say. The Mandelbrot contains an
- infinite amount of fractals! For instance, the needle-point on the right
- has little blobs on it. If you zoom in to the blobs, you will see that they
- are in fact miniature replicas of the original image!
- Also, in between the two big curves to the right of the mouse cursor,
- the edges of the fractal contain many instances of the original images, only
- turned at different angles. Keep trying! You will need about a 32,000X
- magnification to see the first ones.
- Use the right mouse button to examine different points on the graph. For
- instance, the tip of the needle is µ=2. The center of the large circle to
- the right of the mouse is µ=1, and it has a radius of 0.25. The little
- indentation at the left of the image is µ=-0.25.
- ===============================================================================
- BONUS: Also included with MAND is IFSFERN, written in QBasic. It draws
- a fractal "fern" using several complex constants and four simultaneous
- equations. No, I didn't write it; I copied out of an old PC Magazine
- tutor article about fractal compression (I forgot which issue). I also
- forgot what the "IFS" stands for :( , this program was written quite a
- while ago. This program runs a lot faster than MAND because it is not
- iterative──it doesn't keep calculating z²-µ, it just plugs a complex
- number into a normal algebraic function one time and plots its pixel.
- ===============================================================================
- MAND was written in Borland Turbo C++ 3.0 for DOS.
- On my Pentium 133, it takes just under 25 seconds to draw the initial
- screen. I never realized that this program could be used to test a machine's
- computation speed! The computers at school (I am a senior in high school) take
- *forever*. Even their 486SX/40 takes over an hour... If you do have a math
- coprocessor and want to downgrade yourself and see how slowly MAND would run
- with out it, set the environment variable 87 to N by typing SET 87=N at the
- command line; there are no spaces around the equals sign.
-
- Well, that's about it! If you need instructions on using MAND, type
- MAND /? at the command prompt. Have fun!
-
- And now back to your regularly scheduled fourth dimension....
-
-
- How's this for a smiley? A fish about to gulp down a worm on a hook:
-
- >===)))°≥ ~√
-
-
-
- Bye.
-
- +++ATH
- OK
-
-